home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 19 / CU Amiga Magazine's Super CD-ROM 19 (1998)(EMAP Images)(GB)[!][issue 1998-02].iso / CUCD / Programming / ixemul / include / sys / msg.h < prev    next >
C/C++ Source or Header  |  1997-10-28  |  5KB  |  169 lines

  1. /*    $NetBSD: msg.h,v 1.9 1996/02/09 18:25:18 christos Exp $    */
  2.  
  3. /*
  4.  * SVID compatible msg.h file
  5.  *
  6.  * Author:  Daniel Boulet
  7.  *
  8.  * Copyright 1993 Daniel Boulet and RTMX Inc.
  9.  *
  10.  * This system call was implemented by Daniel Boulet under contract from RTMX.
  11.  *
  12.  * Redistribution and use in source forms, with and without modification,
  13.  * are permitted provided that this entire comment appears intact.
  14.  *
  15.  * Redistribution in binary form may occur without any restrictions.
  16.  * Obviously, it would be nice if you gave credit where credit is due
  17.  * but requiring it would be too onerous.
  18.  *
  19.  * This software is provided ``AS IS'' without any warranties of any kind.
  20.  */
  21.  
  22. #ifndef _SYS_MSG_H_
  23. #define _SYS_MSG_H_
  24.  
  25. #include <sys/ipc.h>
  26.  
  27. /* Extra msgctl() cmd defines to retrieve pointers to msginfo and msqids */
  28. #define GETMSGINFO 8
  29. #define GETMSQIDSA 9
  30.  
  31. /*
  32.  * The MSG_NOERROR identifier value, the msqid_ds struct and the msg struct
  33.  * are as defined by the SV API Intel 386 Processor Supplement.
  34.  */
  35.  
  36. #define MSG_NOERROR    010000        /* don't complain about too long msgs */
  37.  
  38. struct msqid_ds {
  39.     struct    ipc_perm msg_perm;    /* msg queue permission bits */
  40.     struct    msg *msg_first;    /* first message in the queue */
  41.     struct    msg *msg_last;    /* last message in the queue */
  42.     u_long    msg_cbytes;    /* number of bytes in use on the queue */
  43.     u_long    msg_qnum;    /* number of msgs in the queue */
  44.     u_long    msg_qbytes;    /* max # of bytes on the queue */
  45.     pid_t    msg_lspid;    /* pid of last msgsnd() */
  46.     pid_t    msg_lrpid;    /* pid of last msgrcv() */
  47.     time_t    msg_stime;    /* time of last msgsnd() */
  48.     long    msg_pad1;
  49.     time_t    msg_rtime;    /* time of last msgrcv() */
  50.     long    msg_pad2;
  51.     time_t    msg_ctime;    /* time of last msgctl() */
  52.     long    msg_pad3;
  53.     long    msg_pad4[4];
  54. };
  55.  
  56. struct msg {
  57.     struct    msg *msg_next;    /* next msg in the chain */
  58.     long    msg_type;    /* type of this message */
  59.                     /* >0 -> type of this message */
  60.                     /* 0 -> free header */
  61.     u_short    msg_ts;        /* size of this message */
  62.     short    msg_spot;    /* location of start of msg in buffer */
  63. };
  64.  
  65. /*
  66.  * Structure describing a message.  The SVID doesn't suggest any
  67.  * particular name for this structure.  There is a reference in the
  68.  * msgop man page that reads "The structure mymsg is an example of what
  69.  * this user defined buffer might look like, and includes the following
  70.  * members:".  This sentence is followed by two lines equivalent
  71.  * to the mtype and mtext field declarations below.  It isn't clear
  72.  * if "mymsg" refers to the naem of the structure type or the name of an
  73.  * instance of the structure...
  74.  */
  75. struct mymsg {
  76.     long    mtype;        /* message type (+ve integer) */
  77.     char    mtext[1];    /* message body */
  78. };
  79.  
  80.  
  81. #ifdef _KERNEL
  82. /*
  83.  * Based on the configuration parameters described in an SVR2 (yes, two)
  84.  * config(1m) man page.
  85.  *
  86.  * Each message is broken up and stored in segments that are msgssz bytes
  87.  * long.  For efficiency reasons, this should be a power of two.  Also,
  88.  * it doesn't make sense if it is less than 8 or greater than about 256.
  89.  * Consequently, msginit in kern/sysv_msg.c checks that msgssz is a power of
  90.  * two between 8 and 1024 inclusive (and panic's if it isn't).
  91.  */
  92. struct msginfo {
  93.     int    msgmax,        /* max chars in a message */
  94.         msgmni,        /* max message queue identifiers */
  95.         msgmnb,        /* max chars in a queue */
  96.         msgtql,        /* max messages in system */
  97.         msgssz,        /* size of a message segment (see notes above) */
  98.         msgseg;        /* number of message segments */
  99. };
  100. //struct msginfo    msginfo;
  101.  
  102. #ifndef MSGSSZ
  103. #define MSGSSZ    8        /* Each segment must be 2^N long */
  104. #endif
  105. #ifndef MSGSEG
  106. #define MSGSEG    2048        /* must be less than 32767 */
  107. #endif
  108. #undef MSGMAX            /* ALWAYS compute MGSMAX! */
  109. #define MSGMAX    (MSGSSZ*MSGSEG)
  110. #ifndef MSGMNB
  111. #define MSGMNB    2048        /* max # of bytes in a queue */
  112. #endif
  113. #ifndef MSGMNI
  114. #define MSGMNI    40
  115. #endif
  116. #ifndef MSGTQL
  117. #define MSGTQL    40
  118. #endif
  119.  
  120. /*
  121.  * macros to convert between msqid_ds's and msqid's.
  122.  * (specific to this implementation)
  123.  */
  124. #define MSQID(ix,ds)    ((ix) & 0xffff | (((ds).msg_perm.seq << 16) & 0xffff0000))
  125. #define MSQID_IX(id)    ((id) & 0xffff)
  126. #define MSQID_SEQ(id)    (((id) >> 16) & 0xffff)
  127. #endif
  128.  
  129. /*
  130.  * The rest of this file is specific to this particular implementation.
  131.  */
  132.  
  133. #ifdef _KERNEL
  134.  
  135. /*
  136.  * Stuff allocated in machdep.h
  137.  */
  138. struct msgmap {
  139.     short    next;        /* next segment in buffer */
  140.                     /* -1 -> available */
  141.                     /* 0..(MSGSEG-1) -> index of next segment */
  142. };
  143.  
  144. #if 0
  145. char *msgpool;            /* MSGMAX byte long msg buffer pool */
  146. struct msgmap *msgmaps;        /* MSGSEG msgmap structures */
  147. struct msg *msghdrs;        /* MSGTQL msg headers */
  148. struct msqid_ds *msqids;    /* MSGMNI msqid_ds struct's */
  149. #endif
  150.  
  151. #define MSG_LOCKED    01000    /* Is this msqid_ds locked? */
  152.  
  153. #endif
  154.  
  155. #ifndef _KERNEL
  156. #include <sys/cdefs.h>
  157.  
  158. __BEGIN_DECLS
  159. int msgctl __P((int, int, struct msqid_ds *));
  160. int msgget __P((key_t, int));
  161. int msgsnd __P((int, void *, size_t, int));
  162. int msgrcv __P((int, void *, size_t, long, int));
  163. __END_DECLS
  164. #else
  165. void msginit __P((void));
  166. #endif /* !_KERNEL */
  167.  
  168. #endif /* !_SYS_MSG_H_ */
  169.